﻿using huaxin_core.Page;
using huaxin_Impl;
using huaxin_Interface;
using huaxin_luckdraw.Models;
using huaxin_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace huaxin_luckdraw.Controllers.api
{
    public class PrizeController : ApiController
    {
        private huaxin_IPrize _prizeInterface = new huaxin_PrizeImpl();

        /// <summary>
        /// 获取中奖记录
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultBase<List<huaxin_prize_extend>> GetPrizeInfoPage([FromBody] PrizeModel para)
        {
            ResultBase<List<huaxin_prize_extend>> resultBase = new ResultBase<List<huaxin_prize_extend>>();

            if (para.pageindex > 0 && para.pagesize > 0)
            {
                resultBase.state = 0;
                resultBase.message = "请求参数错误";
            }
            else
            {
                resultBase.state = 200;
                var data= _prizeInterface.GetPrizePage(para.pageindex, para.pagesize);
                resultBase.data = data.Items.ToList();
                resultBase.total = data.TotalNum;
                resultBase.message = "请求成功";
            }

            return resultBase;

        }

    }
}
